using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing.Design;
using System.Windows.Forms;

namespace LocalizeMe.Sources
{
    public class SourceEditor:UITypeEditor
    {
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            ResourceSource source = value as ResourceSource;

            SourceDesigner frm;

            if (source != null)
                frm = new SourceDesigner(source);
            else
                frm=new SourceDesigner();
                
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    value = frm.Source;
                }
            
            return value;
        }

        public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
        }
    }
}
